<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>数据查看</title>
    <%@include file="../include/commonFile.jsp" %>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">

</head>
<%@include file="../include/header.jsp" %>
<body>
<div class="index-outside">
    <input type="hidden" id="endTime" value="<fmt:formatDate value='${activity.endTime}' pattern='yyyy-MM-dd HH:mm:ss'/>"/>
    <%@include file="../include/sidebar.jsp" %>
    <section>
        <div class="section-main">
            <%--联合发起--->支持者列表--%>
            <div class="layui-tab layui-tab-brief mt20">
                <ul class="layui-tab-title">
                    <c:choose>
                        <c:when test="${isMultiple == true}">
                            <li >众筹<span class="pl5">${activity.joinNum}</span>人</li>
                            <li class="layui-this">联合发起<span class="pl5">${activity.representNum}</span>人</li>
                        </c:when>
                        <c:otherwise>
                            <li class="" id="funding">众筹<span id="total_1" class="pl5">${activity.joinNum - directPayNum}</span>人</li>
                            <li class="layui-this" id="representing">联合发起<span id="total_0" class="pl5">${activity.representNum}</span>人</li>
                            <li class="" id="directPay">直接付款<span id="total_2" class="pl5">${directPayNum}</span>人</li>
                            <li class="" id="transfer">转入<span id="total_3" class="pl5">${transferNum}</span>人</li>
                        </c:otherwise>
                    </c:choose>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item  layui-show">
                        <form class="layui-form"
                              action="${ctx}/crowdfund/support/listForDistributorId.do?id=${activity.id}" id="myForm"
                              method="post">
                            <input type="hidden" name="pageNo" id="pageNo"/>
                            <input type="hidden" name="relationId" value="${relationId}">
                            <input type="hidden" name="name" value="${name}">
                            <div class="f-search-bar">
                                <div class="search-container">
                                    <ul class="search-form-content">
                                        <li class="form-item-inline"><label class="search-form-lable">商户</label>
                                            <div class="layui-input-inline">
                                                <select name="merchantId">
                                                    <option value="">全部</option>
                                                    <c:forEach var="merchant" items="${wechatMerchants}">
                                                        <option value="${merchant.merchantId}" ${merchantId == merchant.merchantId ? 'selected' : ''}>${merchant.merchantName}</option>
                                                    </c:forEach>
                                                </select>
                                            </div>
                                        </li>
                                        <li class="form-item-inline">
                                            <div class="sub-btns">
                                                <a class="layui-btn layui-btn-danger"
                                                   href="javascript:submitFunction('#myForm')">查询</a>
                                                <a class="layui-btn layui-btn-normal"
                                                   href="javascript:resetFunction('#myForm')">重置</a>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </form>
                        <form class="layui-form" action="${ctx}/crowdfund/support/listForDistributorIdExport.do"
                              id="exportForm" method="get">
                            <input type="hidden" name="relationId" value="${relationId}">
                            <input type="hidden" name="name" value="${name}">
                        </form>
                        <div class="my-act-list-content">
                            <ul class="num">
                                <div class="l">
                                    <li class="f16">【${name}】 联合发起的支持人数<span class="red">${page.totalCount}</span>人</li>
                                </div>
                                <div class="r">
                                    <li style="cursor: pointer;" class="r">
                                        <a class="layui-btn layui-btn-danger layui-btn-sm" id="btnExport">导出EXCEL</a>
                                    </li>
                                </div>
                                <p class="cl"></p>
                            </ul>
                            <div class="cl">
                                <table class="layui-table">
                                    <colgroup>
                                        <col width="8%">
                                        <col width="8%">
                                        <col width="10%">
                                        <col width="8%">
                                        <col width="8%">
                                        <col width="8%">
                                        <col width="8%">
                                        <col width="8%">
                                        <col width="10%">
                                    </colgroup>
                                    <thead>
                                    <tr>
                                        <th>支持者</th>
                                        <th>支持时间</th>
                                        <th>公司</th>
                                        <th>职务</th>
                                        <th>联系电话</th>
                                        <th>支持金额</th>
                                        <th>状态</th>
                                        <th>商户名称</th>
                                        <th>操作</th>
                                    </tr>

                                    </thead>
                                    <tbody>
                                    <c:forEach var="directPay" items="${list}">
                                        <tr>
                                            <td class="table-member"
                                                onclick="openDialogShow('用户名片','${ctx}/system/member/memberView.do?id=${directPay.favorerId}','400px','470px')">
                                                <div class="member-cell">
                                                    <div class="member-logo common-img">
                                                        <img src="<c:if test="${ directPay.favorerLogo!= null}">${directPay.favorerLogo}?imageMogr2/auto-orient/crop/126x126</c:if>" alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                                    </div>
                                                    <div class="member-name ellipsis-1"><a class="blue"
                                                                                           title="${directPay.favorerName}"
                                                                                           href="javascript:void(0);">${directPay.favorerName}</a>
                                                    </div>
                                                </div>
                                            </td>
                                            <td>
                                                <fmt:formatDate value="${directPay.createDate}" pattern="yyyy-MM-dd HH:mm"/>
                                            </td>
                                            <td>
                                                <div class="ellipsis-1"
                                                     title="${directPay.favorerCompany}">${directPay.favorerCompany}</div>
                                            </td>
                                            <td>
                                                    ${directPay.favorerJobTitle}
                                            </td>
                                            <td>
                                                    ${directPay.favorerMobile}
                                            </td>
                                            <td>
                                                <fmt:formatNumber pattern="0.00" value="${directPay.payment}"/>
                                            </td>
                                            <td>
                                                <c:if test="${directPay.payStatus == 0}">
                                                    <a class="blue" title="待支付"
                                                       href="javascript:openDialogNoButton('订单详情','${ctx}/order/order/orderInfo.do?id=${directPay.orderId}','450px','570px')">待支付</a>
                                                </c:if>
                                                <c:if test="${directPay.payStatus == 1}">
                                                    <a class="blue" title="支付成功"
                                                       href="javascript:openDialogNoButton('订单详情','${ctx}/order/order/orderInfo.do?id=${directPay.orderId}','450px','570px')">支付成功</a>
                                                </c:if>
                                                <c:if test="${directPay.payStatus == 2}">
                                                    <a class="blue" title="退款中"
                                                       href="javascript:openDialogNoButton('订单详情','${ctx}/order/order/orderInfo.do?id=${directPay.orderId}','450px','570px')">退款中</a>
                                                </c:if>
                                                <c:if test="${directPay.payStatus == 3}">
                                                    <a class="blue" title="退款成功"
                                                       href="javascript:openDialogNoButton('订单详情','${ctx}/order/order/orderInfo.do?id=${directPay.orderId}','450px','570px')">退款成功</a>
                                                </c:if>
                                                <c:if test="${directPay.payStatus == 4}">
                                                    <a class="blue" title="退款失败"
                                                       href="javascript:openDialogNoButton('订单详情','${ctx}/order/order/orderInfo.do?id=${directPay.orderId}','450px','570px')">退款失败</a>
                                                </c:if>
                                            </td>
                                            <td>
                                                ${directPay.merchantName}
                                            </td>
                                            <td class="tb-opts">
                                                <div class="comm-opts">
                                                    <c:if test="${directPay.payStatus == 1 || directPay.payStatus == 4}">
                                                        <a href="javascript:refund('${directPay.id}');"
                                                           target="_self">
                                                            退款
                                                        </a>
                                                    </c:if>
                                                </div>
                                            </td>
                                        </tr>
                                    </c:forEach>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div id="page_content" class="page-container"></div>
                    </div>
                    <div class="layui-tab-item">

                    </div>
                </div>
            </div>
        </div><%@include file="../include/footer.jsp" %>
    </section>
</div>

<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript" src="${ctx}/script/common/common-refund.js"></script>
<script type="text/javascript">
    const regex = /^[a-zA-Z0-9]{6,20}$/;
    var laytpl = null;
    var laypage = null;
    var element = null;
    txz.initHeader({
        nav:[{
            name: '众筹项目管理',
            href:'${ctx}/activity/activity/zcActivityList.do',
        },{
            name: '${activity.title}'
        },{
            name: '数据查看',
            curr: true
        }],
        info:'<span class="f12">共<b>${page.totalCount}</b>条记录',
        btns:[{
            type: 'add',
            name: '返回',
            icon: 'back',
            href: 'javascript:window.history.back()'
        }]
    });
    $(function () {

        //加载分页
        loadPageNew({elem: 'page_content', totalCount: '${page.totalCount}', limit: '${page.limit}', page: '${page.page}'});

        if (${isMultiple == true}) {
            $("#myForm").attr('action', '${ctx}/activityMultiple/support/activity/listForDistributor.do?id=${activity.id}');
        }

        layui.use(['laytpl', 'laypage', 'element', 'form'], function () {
            laytpl = layui.laytpl;
            laypage = layui.laypage;
            element = layui.element;


            element.on('tab', function (data) {
                if (${isMultiple == true}) {
                    if (data.index == 0) {
                        window.location.href = "${ctx}/activityMultiple/project/listForActivity.do?id=${activity.id}";
                    } else if (data.index == 1) {
                        window.location.href = "${ctx}/activityMultiple/represent/listForActivity.do?id=${activity.id}";
                    }
                } else {
                    if (data.index == 0) {
                        window.location.href = "${ctx}/activity/activity/zcCrowdfundList.do?id=${activity.id}";
                    } else if (data.index == 1) {
                        window.location.href = "${ctx}/activity/activity/zcRepresentList.do?id=${activity.id}";
                    } else if (data.index == 2) {
                        window.location.href = "${ctx}/activity/activity/zcDirectPayList.do?id=${activity.id}";
                    } else if(data.index == 3){
                        window.location.href = "${ctx}/activity/activity/zcShiftToPeopleList.do?id=${activity.id}";
                    }
                }
            });

            var form = layui.form;
            form.verify({
                oldPassword: function (value) {
                    if (value == "") {
                        return "原退款密码不能为空";
                    } else if (!regex.test(value)) {
                        return "原退款密码格式不正确";
                    }
                },
                newPassword: function (value) {
                    if (value == "") {
                        return "新退款密码不能为空";
                    } else if (!regex.test(value)) {
                        return "新退款密码格式不正确";
                    }
                },
                confirmPassword: function (value) {
                    var pwd = $("#findpwd_form").find("[name=newPassword]").val();
                    if (value == "") {
                        return "确认密码不能为空";
                    } else if (!regex.test(value)) {
                        return "确认密码格式不正确";
                    } else if (pwd != value) {
                        return "确认密码与新密码不匹配";
                    }
                }
            });
        });

        $("#cancel_btn").click(function () {
            $(this).closest('.f-def-dialog').fadeOut();
        });

        $("#btnExport").click(function () {
            layer.confirm('确认要导出Excel吗?', {
                icon: 3,
                title: '系统提示'
            }, function (index) {
                var url = $("#exportForm").attr("action");
                var loadIndex = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                });
                var params = $("#exportForm").serializeArray();
                params.push({
                    name : 'merchantId',
                    value : $("[name=merchantId]").find("option:selected").val()
                });
                $.post(url, params, function (res) {
                    top.layer.close(loadIndex);
                    if (res.success) {
                        window.location.href = res.data;
                    } else {
                        util.layerMsgError(res.description)
                    }
                });
                top.layer.close(index);
            });
        });
    });

    function refund(id) {
        txzRefund.doRefundOpt('${ctx}/crowdfund/support/refund.do', {
            id: id
        }, '${activity.id}')
    }
</script>
</body>
</html>
